<?php
// Do not delete these lines
	if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
		die ('Please do not load this page directly. Thanks!');

	if ( post_password_required() ) { ?>
		<p class="nocomments">This post is password protected. Enter the password to view comments.</p>
	<?php
		return;
	}
?>

<?php
function mytheme_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>

<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
	<div id="comment-<?php comment_ID(); ?>">
		<?php echo get_avatar($comment,$size='60',$default=get_template_directory_uri().'/styles/_shared/gravatar.gif' ); ?>
		<div class="comment-text">
			<cite><?php comment_author_link() ?></cite><span class="date"><?php comment_date('m-d-y'); ?></span><br />
			<?php if ($comment->comment_approved == '0') : ?>
				<span class="awaiting_moderation"><?php _e('Your comment is awaiting moderation.') ?></span><br />
			<?php endif; ?>
			<?php comment_text() ?>
			<div class="comment-meta commentmetadata">
				<?php comment_reply_link(array_merge( $args, array('reply_text' => '(reply)', 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>  <?php edit_comment_link(__('(edit)'),' ','') ?> 
			</div>
		</div>
	</div>
<?php }

function list_pings($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>

<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
	<cite><?php comment_author_link() ?></cite><span class="date"><?php comment_date('m-d-y'); ?></span><br />

<?php } ?>


		
<?php if  ( have_comments() ) : ?>
<?php $count = count($comments_by_type['comment']); ($count !== 1) ? $txt = "Comments" : $txt = "Comment";?>
<?php $count_tb = count($comments_by_type['pings']); ($count !== 1) ? $txt_tb = "Trackbacks" : $txt_tb = "Trackback";?>

<div class="minimal_arrow_tab_set">
	<ul class="tabs">
		<li><a href="#"><?php echo "(" .$count . ") " . $txt; ?></a></li>
		<li><a href="#"><?php echo "(" .$count_tb . ") " . $txt_tb; ?></a></li>
	</ul>
	
<div class="tab_content">
	
<?php if ( ! empty($comments_by_type['comment']) ) : ?>
<ol class="commentlist">
	<?php //wp_list_comments('avatar_size=60'); ?>
	<?php wp_list_comments('callback=mytheme_comment&type=comment'); ?>
</ol>
	
<div class="comms-navigation">
    <div style="float:left"><?php previous_comments_link() ?></div>
    <div style="float:right"><?php next_comments_link() ?></div>
</div>
<?php endif; ?>

<?php
else : // no comments so far
    if ('open' == $post->comment_status) :
        // If comments are open, but there are no comments.
    else :
        //if ( is_single() ){ echo"<p>Comments are closed on this post.</p>"; }
    endif;
endif;


// Comment Form
if ('open' == $post->comment_status) : ?>

<div id="respond">
	<h3><?php comment_form_title( 'Leave a Reply', 'Leave a Reply to %s' ); ?></h3>
    <div class="cancel-comment-reply">
        <?php cancel_comment_reply_link(); ?>
    </div>
	<?php if ( get_option('comment_registration') && !$user_ID ) : ?>
	<p>You must be <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php echo urlencode(get_permalink()); ?>">logged in</a> to post a comment.</p>
    <?php else : ?>
   	<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
	<?php if ( $user_ID ) : ?>
	<p class="logged">Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="Log out of this account">Log out &raquo;</a></p>
	<?php else : ?>
	<p><input type="text" class="textfield" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" /><label  class="textfield_label" for="author">Name *</label></p>
	<p><input type="text" class="textfield" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" tabindex="2" /><label class="textfield_label" for="email">Email *</label></p>
	<p><input type="text" class="textfield" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="22" tabindex="3" /><label  class="textfield_label" for="url">Website</label></p>
	<?php endif; ?>
	<p><textarea class="textarea" name="comment" id="comment" cols="70" rows="10" tabindex="4"></textarea></p>
	<p><button type="submit" class="fancy_button" value="Submit Comment" ><span>Submit Comment</span></button><?php comment_id_fields(); ?></p>
	<p><?php do_action('comment_form', $post->ID); ?></p>
	</form>	
<?php endif; // If registration required and not logged in ?>
</div><!--/respond-->

<?php endif; ?>



<?php //trackbacks
if ( have_comments() ) : ?>
	</div><!-- comments tab -->
		<div class="tab_content">
			
<?php if ( ! empty($comments_by_type['pings']) ) : ?>
<ol class="commentlist">
	<?php wp_list_comments('callback=list_pings&type=pings'); ?>
</ol>

<div class="comms-navigation">
    <div style="float:left"><?php previous_comments_link() ?></div>
    <div style="float:right"><?php next_comments_link() ?></div>
</div>
<?php endif; ?>

	</div><!-- trackback tab -->
</div><!-- minimal_arrow_tab_set -->

<?php
else : // no comments so far
    if ('open' == $post->comment_status) :
        // If comments are open, but there are no comments.
    else :
        //if ( is_single() ){ echo"<p>Comments are closed on this post.</p>"; }
    endif;
endif; ?>